#include "DXUT.h"

#ifndef LOADER_H
#define LOADER_H

#include "IThread.h"

class World;
#include "World.h"

#include <queue>

#define LSIZE 32

struct rgnQueue {
	ULONGLONG	time;
	Region *	region;
	Chunk  *	chunk;
};

class Loader : public IThread {
private:
	World*				m_pWorld;
	D3DXVECTOR3			m_LastEye;

	byte *				m_loadedChunks;

	int					dx;
	int					dz;
	int					m_ID;

	std::queue<rgnQueue>	unloadRegionQueue;

	bool updatePosition(byte * loadedChunks);

	void workQueue(bool removeAll);
	void fillQueue(int x, int z);
protected:
	static DWORD WINAPI run( LPVOID pParam );
public:
	Loader(World* pWorld, int ID = 0);
	~Loader();

	void setStatus( int status );
	void setValue( void * userData ) {};
};

#endif